﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace AwesomeEnginePC.Graphics
{
    public abstract class BaseGraphicalObject
    {
        /// <summary>
        /// The imported Content Manager from which to load content from.
        /// </summary>
        protected ContentManager CM
        {
            get;
            private set;
        }

        /// <summary>
        /// The asset string to load from the ContentManager.
        /// </summary>
        public virtual String ContentAssetName { get; set; }

        /// <summary>
        /// Describes if the object is able to be drawn.
        /// </summary>
        public virtual bool Active { get; set; }


        public BaseGraphicalObject(ContentManager cm)
        {
            ContentAssetName = "Content";
            Active = false;
            CM = cm;
        }

        /// <summary>
        /// Loads a content from the given ContentManager with the stored AssetName.
        /// </summary>
        /// <typeparam name="T">The datatype to load.</typeparam>
        /// <param name="CM">The ContentManager to load the content from.</param>
        /// <returns>An instance of the datatype inputted from the given ContentManager.</returns>
        protected T LoadContent<T>(ContentManager CM)
        {
            Active = true;
            return CM.Load<T>(ContentAssetName);
        }

        /// <summary>
        /// Loads a content from the given ContentManager with the given AssetName.
        /// </summary>
        /// <typeparam name="T">The datatype to load.</typeparam>
        /// <param name="CM">The ContentManager to load the content from.</param>
        /// <param name="AssetName">The AssetName to load.</param>
        /// <returns>An instance of the datatype inputted from the given ContentManager.</returns>
        protected T LoadContent<T>(ContentManager CM, string AssetName)
        {
            Active = true;
            ContentAssetName = AssetName;
            return CM.Load<T>(AssetName);
        }

        /// <summary>
        /// Loads a content from the stored ContentManager with the given AssetName.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="AssetName"></param>
        /// <returns></returns>
        protected T LoadContent<T>(string AssetName)
        {
            Active = true;
            ContentAssetName = AssetName;
            return CM.Load<T>(AssetName);
        }

        /// <summary>
        /// The default draw function. Allows the program to draw the class to the screen.
        /// </summary>
        /// <param name="gameTime">The current GameTime.</param>
        /// <param name="SB">The SpriteBatch to draw to.</param>
        public abstract void Draw(GameTime gameTime, SpriteBatch sb);

        /// <summary>
        /// Default Update function, allows the class to update its state.
        /// </summary>
        /// <param name="gameTime">The current GameTime.</param>
        public abstract void Update(GameTime gameTime);
    }
}
